<?php

/**
 * Index controller class
 *
 */

class AjaxController extends Client_Controller
{
	public function init()
    {
        parent::init();
        $this->table_regions = new Client_Table_Regions($this->_lang);
    }

    public function districtListAction()
    {
    	$id  = $this->_getParam('id_region');
		$default = '<option value="0"> - Всі -</option>';

		if($id > 0)
		{
			$data = $this->table_regions->GetDistrictList(null, $id);
			if(count($data) > 0)
			{
				$output = $default;
				foreach ($data as $k => $v)
					$output .= '<option value="' . $v['id'] . '" rel="'.$v['koatuu'].'">' . $v['name'] . '</option>';

				$this->ajaxOut($output);
			}
		}

    	$this->ajaxOut($default);
    }

    public function citiesListAction()
    {
    	$id  = $this->_getParam('id_district');
		$default = '<option value="0"> - Всі -</option>';

		if($id > 0)
		{
			$data = $this->table_regions->GetCitiesList(null, null, $id);
			if(count($data) > 0)
			{
				$output = $default;
				foreach ($data as $k => $v)
					$output .= '<option value="' . $v['id'] . '" rel="'.$v['koatuu'].'">' . $v['name'] . '</option>';

				$this->ajaxOut($output);
			}
		}

    	$this->ajaxOut($default);
    }




     public function viewAction()
     {
     	die('view');
     }

}
